/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ec.medical.entidades;

import com.ec.medical.interfaces.Imprimible;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "sexo_persona")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SexoPersona.findAll", query = "SELECT s FROM SexoPersona s"),
    @NamedQuery(name = "SexoPersona.findByCodigoSexoPersona", query = "SELECT s FROM SexoPersona s WHERE s.codigoSexoPersona = :codigoSexoPersona"),
    @NamedQuery(name = "SexoPersona.findByNombre", query = "SELECT s FROM SexoPersona s WHERE s.nombre = :nombre")})
public class SexoPersona implements Serializable,Imprimible {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "codigo_sexo_persona")
    private Integer codigoSexoPersona;
    @NotNull(message="Nombre es obligatorio")
    @Basic(optional = false)
    @Size(min=1, max=15,message="Nombre debe poseer maximo 15 caracteres")
    @Column(name = "nombre")
    private String nombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "sexoPersona")
    private List<Cliente> clientes;

    public SexoPersona() {
    }

    public SexoPersona(Integer codigoSexoPersona) {
        this.codigoSexoPersona = codigoSexoPersona;
    }

    public SexoPersona(Integer codigoSexoPersona, String nombre) {
        this.codigoSexoPersona = codigoSexoPersona;
        this.nombre = nombre;
    }

    public Integer getCodigoSexoPersona() {
        return codigoSexoPersona;
    }

    public void setCodigoSexoPersona(Integer codigoSexoPersona) {
        this.codigoSexoPersona = codigoSexoPersona;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    @XmlTransient
    public List<Cliente> getClientes() {
        return clientes;
    }

    public void setClientes(List<Cliente> clientes) {
        this.clientes = clientes;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigoSexoPersona != null ? codigoSexoPersona.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SexoPersona)) {
            return false;
        }
        SexoPersona other = (SexoPersona) object;
        if ((this.codigoSexoPersona == null && other.codigoSexoPersona != null) || (this.codigoSexoPersona != null && !this.codigoSexoPersona.equals(other.codigoSexoPersona))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.SexoPersona[ codigoSexoPersona=" + codigoSexoPersona + " ]";
    }

    @Override
    public String getEtiqueta() {
        return getNombre();
    }

    @Override
    public Object getObjecto() {
        return this;
    }
    
}